﻿@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Form.cshtml";
}
@System.Web.Optimization.Styles.Render("~/Content/scripts/plugins/jqgrid/css")
@System.Web.Optimization.Scripts.Render("~/Content/scripts/plugins/jqgrid/js")
<script>
    var keyValue = request('keyValue');
    var PStructName = decodeURI(request('PStructName'));
    $(function () {
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../ResourceManage/RS_PStructUser/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    
                    $("#form1").SetWebControls(data);
                    if (data.Flag == 0) {
                        $("#Flag").val("公司");
                        GetGrid(0);
                    } else {
                        $("#Flag").val("个人");
                        $(".Enterprise").attr("hidden", "hidden");
                        flagHtml = $("#isFlag").next().html();
                        $("#isFlag").next().html("");
                        $("#isEnterprise").html("名称");
                        $("#CampanyName").attr("id", "Name");
                        $("#Name").val(data.Name);
                        GetGrid(1);
                    }
                    if (data.Type == 0) {
                        $("#Type").val("业主");
                    } else {
                        $("#Type").val("租户");
                        $("#isType").text("入住时间");
                        $("#PurchaseTime").attr("id", "CheckinTime");
                        $("#CheckinTime").val(data.CheckinTime);
                    }
                    if (data.Gender != null && data.Gender != "") {
                        if (data.Gender == 0) {
                            $("#Gender").val("男");
                        } else { $("#Gender").val("女"); }
                    }
                    $("#PStructName").val(PStructName);
                }
            });
        }
    })
    //加载表格
    function GetGrid(type) {
        var _url = "";
        var _colModel=[];
        if (type == 0) { _url = "../../ResourceManage/RS_PStructUser/GetLinkManJson?customerId=" + keyValue; _colModel=[
                { label: "主键", name: "Id", index: "Id", hidden: true },
                { label: "名称", name: "Name", index: "Name", width: 150, align: "left" },
                {
                    label: "性别", name: "Gender", index: "Gender", width: 70, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == 1 ? "<span>女</span>" : "<span>男</span>";
                    }
                },
                { label: "手机号码", name: "Phone", index: "Phone", width: 150, align: "left" },
                { label: "电话号码", name: "LinkPhone", index: "LinkPhone", width: 150, align: "center" },
                { label: "身份证号", name: "IDCard", index: "LinkPhone", width: 150, align: "center" }
        ]; }
        else { _url = "../../ResourceManage/RS_PStructUser/GetFamilyJson?customerId=" + keyValue;_colModel=[
                { label: "主键", name: "Id", index: "Id", hidden: true },
                { label: "名称", name: "Name", index: "Name", width: 150, align: "left" },
                {
                    label: "性别", name: "Gender", index: "Gender", width: 70, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == 1 ? "<span>女</span>" : "<span>男</span>";
                    }
                },
                { label: "关系", name: "Relationship", index: "Relationship", width: 150, align: "left" },
                { label: "手机号码", name: "Phone", index: "Phone", width: 150, align: "left" },
                { label: "电话号码", name: "LinkPhone", index: "LinkPhone", width: 150, align: "center" },
                { label: "身份证号", name: "IDCard", index: "LinkPhone", width: 150, align: "center" }
        ]; }
        var $gridTable = $('#gridTable1');
        $gridTable.jqGrid({
            url: _url,
            datatype: "json",
            height: $(window).height() - 141.5,
            autowidth: true,
            colModel: _colModel,
            pager: false,
            rowNum: "1000",
            rownumbers: true,
            shrinkToFit: false,
            gridview: true,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            }
        });
    }
</script>
<div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
    <div class="ui-layout-center">
        <div class="center-Panel" style="margin-left:5px;">
            <div class="panel-Title">基本资料</div>
            <div class="gridPanel">
                <table class="form">
                    <tr>
                        <th class="formTitle">住户类别</th>
                        <td class="formValue">
                            <input id="Flag" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">所属房间</th>
                        <td class="formValue">
                            <input id="PStructName" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle" id="isEnterprise">公司名称</th>
                        <td class="formValue">
                            <input id="CampanyName" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">编码</th>
                        <td class="formValue">
                            <input id="Code" type="text" class="form-control" disabled />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">住户类型</th>
                        <td class="formValue">
                            <input id="Type" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle" id="isType">购买时间</th>
                        <td class="formValue">
                            <input id="PurchaseTime" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">手机号码</th>
                        <td class="formValue">
                            <input id="Phone" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">联系电话</th>
                        <td class="formValue">
                            <input id="LinkPhone" type="text" class="form-control" disabled />
                        </td>
                    </tr>
                    <tr class="Enterprise">
                        <th class="formTitle">经营种类</th>
                        <td class="formValue">
                            <input id="BCategory" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">经营品牌</th>
                        <td class="formValue">
                            <input id="Brand" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">营业执照号</th>
                        <td class="formValue">
                            <input id="License" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle" id="isFlag">法人名称</th>
                        <td class="formValue">
                            <input id="Name" type="text" class="form-control" disabled />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">联系地址</th>
                        <td class="formValue">
                            <input id="LinkAddress" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">出生年月</th>
                        <td class="formValue">
                            <input id="Birth" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">性别</th>
                        <td class="formValue">
                            <input id="Gender" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">身份证号</th>
                        <td class="formValue">
                            <input id="IDCard" type="text" class="form-control" disabled />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">民族</th>
                        <td class="formValue">
                            <input id="Nation" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">家庭住址</th>
                        <td class="formValue">
                            <input id="Address" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">Fax</th>
                        <td class="formValue">
                            <input id="Fax" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">Email</th>
                        <td class="formValue">
                            <input id="Email" type="text" class="form-control" disabled />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">WebChat</th>
                        <td class="formValue">
                            <input id="WeChat" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle">QQ</th>
                        <td class="formValue">
                            <input id="QQ" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle Enterprise">紧急联系人</th>
                        <td class="formValue Enterprise">
                            <input id="LinkName" type="text" class="form-control" disabled />
                        </td>
                        <th class="formTitle Enterprise">紧急联系电话</th>
                        <td class="formValue Enterprise">
                            <input id="LinkPhone1" type="text" class="form-control" disabled />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="center-Panel" style="margin-left:5px;">
            <div class="panel-Title">联系人</div>
            <div class="gridPanel" style="width:867px;" >
                <table id="gridTable1" style="width:867px;"></table>
            </div>
        </div>
    </div>
</div>